package com.pro.controller;

import com.pro.pojo.*;
import com.pro.service.JsBeforeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
* @Title: 用户的controller层
* @author Administrator
* @date 2022/1/23 0023 19:07
* @version V1.0
*/
@Controller
@RequestMapping(value = "/user")
public class JsBeforeUserController {
    @Autowired
    private JsBeforeUserService beforeUserService;

    /**
    * @Title: 获取所有用户
    * @author 许振杰
    * @date 2022/1/23 0023 19:57
    * @version V1.0
    */
    @RequestMapping(value = "getBeforeUser")
    @ResponseBody
    public JsonData getBeforeUser(String account,String nickname,String createDate){
        List<JsBeforeUser> beforeUser = beforeUserService.getBeforeUser(account, nickname, createDate);
        return beforeUser != null ? JsonData.buildSuccess(beforeUser) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 用户的高级检索
    * @author 许振杰
    * @date 2022/1/23 0023 20:47
    * @version V1.0
    */
    @RequestMapping(value = "advancedRetrieval")
    @ResponseBody
    public JsonData advancedRetrieval(JsBeforeUser beforeUser){
        List<JsBeforeUser> jsBeforeUsers = beforeUserService.advancedRetrieval(beforeUser);
        return jsBeforeUsers != null ? JsonData.buildSuccess(jsBeforeUsers) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 修改用户信息
    * @author 许振杰
    * @date 2022/1/23 0023 22:04
    * @version V1.0
    */
    @RequestMapping(value = "editBeforeUserByUserId")
    @ResponseBody
    public JsonData editBeforeUserByUserId(JsBeforeUser beforeUser){
        boolean editBeforeUserByUserId = beforeUserService.editBeforeUserByUserId(beforeUser);
        return editBeforeUserByUserId ? JsonData.buildSuccess(editBeforeUserByUserId) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 修改用户状态
    * @author 许振杰
    * @date 2022/1/23 0023 22:05
    * @version V1.0
    */
    @RequestMapping(value = "editBeforeUserStatus")
    @ResponseBody
    public JsonData editBeforeUserStatus(Integer userId,Integer status){
        boolean editBeforeUserStatus = beforeUserService.editBeforeUserStatus(userId, status);
        return editBeforeUserStatus ? JsonData.buildSuccess(editBeforeUserStatus) : JsonData.buildError("服务器出错了");
    }

    /**
     * @Title: 添加封停日志
     * @author 许振杰
     * @date 2022/1/24 0024 15:37
     * @version V1.0
     */
    @RequestMapping(value = "addclosure")
    @ResponseBody
    public JsonData  addclosure(JsClosure closure){
        boolean addclosure = beforeUserService.addclosure(closure);
        return addclosure ? JsonData.buildSuccess(addclosure) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 添加用户
    * @author 许振杰
    * @date 2022/1/26 0026 20:23
    * @version V1.0
    */
    @RequestMapping(value = "addBeforeUser")
    @ResponseBody
    public JsonData addBeforeUser(JsBeforeUser beforeUser){
        boolean addBeforeUser = beforeUserService.addBeforeUser(beforeUser);
        return addBeforeUser ? JsonData.buildSuccess(addBeforeUser) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据学号查询用户id
    * @author 许振杰
    * @date 2022/1/26 0026 20:26
    * @version V1.0
    */
    @RequestMapping(value = "getUserId")
    @ResponseBody
    public JsonData getUserId(JsBeforeUser beforeUser){
        List<JsBeforeUser> getUserId = beforeUserService.getUserId(beforeUser);
        return getUserId != null ? JsonData.buildSuccess(getUserId) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 添加进思用户
    * @author 许振杰
    * @date 2022/1/26 0026 20:27
    * @version V1.0
    */
    @RequestMapping(value = "addUserDevelopment")
    @ResponseBody
    public JsonData addUserDevelopment(JsUserDevelopment userDevelopment){
        boolean addUserDevelopment = beforeUserService.addUserDevelopment(userDevelopment);
        return addUserDevelopment ? JsonData.buildSuccess(addUserDevelopment) : JsonData.buildError("服务器出错了");
    }


    /**
    * @Title: 优惠卷列表
    * @author 许振杰
    * @date 2022/1/26 0026 14:08
    * @version V1.0
    */
    @RequestMapping(value = "getAllUserCoupon")
    @ResponseBody
    public JsonData  getAllUserCoupon(){
        List<JsUserCoupon> allUserCoupon = beforeUserService.getAllUserCoupon();
        return allUserCoupon!=null ? JsonData.buildSuccess(allUserCoupon) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 根据id查询优惠卷的发行数量和使用数量
    * @author 许振杰
    * @date 2022/1/26 0026 15:25
    * @version V1.0
    */
    @RequestMapping(value = "getUserCouponById")
    @ResponseBody
    public JsonData  getUserCouponById(JsUserCoupon jsUserCoupon){
        JsUserCoupon userCouponById = beforeUserService.getUserCouponById(jsUserCoupon);
        return userCouponById!=null ? JsonData.buildSuccess(userCouponById) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 修改优惠卷发行数量
    * @author 许振杰
    * @date 2022/1/26 0026 15:41
    * @version V1.0
    */
    @RequestMapping(value = "editUserCouponByUsed")
    @ResponseBody
    public JsonData  editUserCouponByUsed(Integer couponId,Integer used){
        boolean editUserCouponByUsed = beforeUserService.editUserCouponByUsed(couponId, used);
        return editUserCouponByUsed ? JsonData.buildSuccess(editUserCouponByUsed) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 添加优惠卷使用记录
    * @author 许振杰
    * @date 2022/1/26 0026 15:42
    * @version V1.0
    */
    @RequestMapping(value = "addUserCouponUsed")
    @ResponseBody
    public JsonData  addUserCouponUsed(JsUserCouponUsed userCouponUsed){
        boolean addUserCouponUsed = beforeUserService.addUserCouponUsed(userCouponUsed);
        return addUserCouponUsed ? JsonData.buildSuccess(addUserCouponUsed) : JsonData.buildError("服务器出错了");
    }


    /**
    * @Title: 进思用户列表
    * @author Administrator
    * @date 2022/1/24 0024 19:54
    * @version V1.0
    */
    @RequestMapping(value = "getUserDevelopment")
    @ResponseBody
    public JsonData getUserDevelopment(JsBeforeUser beforeUser){
        List<JsBeforeUser> userDevelopment = beforeUserService.getUserDevelopment(beforeUser);
        return userDevelopment != null ? JsonData.buildSuccess(userDevelopment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 进思用户列表的高级检索
    * @author 许振杰
    * @date 2022/1/24 0024 19:55
    * @version V1.0
    */
    @RequestMapping(value = "userDevelopmentAdvancedRetrieval")
    @ResponseBody
    public JsonData userDevelopmentAdvancedRetrieval(JsBeforeUser beforeUser){
        List<JsBeforeUser> userDevelopmentAdvancedRetrieval = beforeUserService.userDevelopmentAdvancedRetrieval(beforeUser);
        return userDevelopmentAdvancedRetrieval != null ? JsonData.buildSuccess(userDevelopmentAdvancedRetrieval) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 非进思用户列表
    * @author 许振杰
    * @date 2022/1/24 0024 21:32
    * @version V1.0
    */
    @RequestMapping(value = "getNotUserDevelopment")
    @ResponseBody
    public JsonData getNotUserDevelopment(JsBeforeUser beforeUser){
        List<JsBeforeUser> notUserDevelopment = beforeUserService.getNotUserDevelopment(beforeUser);
        return notUserDevelopment != null ? JsonData.buildSuccess(notUserDevelopment) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 非进思用户的高级检索
    * @author 许振杰
    * @date 2022/2/21 0021 9:11
    * @version V1.0
    */
    @RequestMapping(value = "notUserDevelopmentAdvancedRetrieval")
    @ResponseBody
    public JsonData notUserDevelopmentAdvancedRetrieval(JsBeforeUser beforeUser){
        List<JsBeforeUser> userDevelopmentAdvancedRetrieval = beforeUserService.notUserDevelopmentAdvancedRetrieval(beforeUser);
        return userDevelopmentAdvancedRetrieval != null ? JsonData.buildSuccess(userDevelopmentAdvancedRetrieval) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 零消费用户列表
    * @author 许振杰
    * @date 2022/1/24 0024 21:33
    * @version V1.0
    */
    @RequestMapping(value = "getNotConsumptionBeforeUser")
    @ResponseBody
    public JsonData getNotConsumptionBeforeUser(JsBeforeUser beforeUser){
        List<JsBeforeUser> notConsumptionBeforeUser = beforeUserService.getNotConsumptionBeforeUser(beforeUser);
        return notConsumptionBeforeUser != null ? JsonData.buildSuccess(notConsumptionBeforeUser) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 零消费用户的高级检索
    * @author 许振杰
    * @date 2022/2/21 0021 9:13
    * @version V1.0
    */
    @RequestMapping(value = "notConsumptionBeforeUserAdvancedRetrieval")
    @ResponseBody
    public JsonData notConsumptionBeforeUserAdvancedRetrieval(JsBeforeUser beforeUser){
        List<JsBeforeUser> jsBeforeUsers = beforeUserService.notConsumptionBeforeUserAdvancedRetrieval(beforeUser);
        return jsBeforeUsers != null ? JsonData.buildSuccess(jsBeforeUsers) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 修改前端用户信息
    * @author 许振杰
    * @date 2022/2/9 0009 19:35
    * @version V1.0
    */
    @RequestMapping(value = "editBeforeUser")
    @ResponseBody
    public JsonData editBeforeUser(JsBeforeUser beforeUser){
        boolean editBeforeUser = beforeUserService.editBeforeUser(beforeUser);
        return editBeforeUser ? JsonData.buildSuccess(editBeforeUser) : JsonData.buildError("服务器出错了");
    }

    /**
    * @Title: 修改进思用户信息
    * @author 许振杰
    * @date 2022/2/9 0009 19:40
    * @version V1.0
    */
    @RequestMapping(value = "editJinsiUser")
    @ResponseBody
    public JsonData editJinsiUser(JsUserDevelopment userDevelopment){
        boolean editJinsiUser = beforeUserService.editJinsiUser(userDevelopment);
        return editJinsiUser ? JsonData.buildSuccess(editJinsiUser) : JsonData.buildError("服务器出错了");
    }

}
